import request from "@/utils/request";
import { parseStrEmpty } from "@/utils/ruoyi";
import {
  listUser_,
  addAccUser_,
  eidtUser_,
  delUser_,
  cangkuSel_,
  userSel_,
  eidUserState_,
  editUserHuiXian_,
  eidtVcode_,
  resetPwd_,
} from "../urlApi";
import qs from "qs";
// 查询用户列表
export function listUser(data) {
  return request({
    url: listUser_,
    method: "post",
    data: qs.stringify(data),
  });
}
// 新增用户
export function addUser(data) {
  return request({
    url: addAccUser_,
    headers: {
      // repeatSubmit: true,
      "Content-Type": "application/json",
    },
    method: "post",
    data: JSON.stringify(data),
  });
}

// 用户状态修改
export function changeUserStatus(data) {
  return request({
    url: eidUserState_,
    method: "post",
    data: qs.stringify(data),
  });
}

// 删除用户
export function delUser(data) {
  return request({
    url: delUser_,
    method: "post",
    data: qs.stringify(data),
  });
}
// 查询授权角色
export function getAuthRole(data) {
  return request({
    url: userSel_,
    method: "post",
    data: qs.stringify(data),
  });
}
// 查询授权仓库
export function cangkuSel(data) {
  return request({
    url: cangkuSel_,
    method: "post",
    data: qs.stringify(data),
  });
}

// export function EcartsCangku(data) {
//   return request({
//     url: EcartsCangku_,
//     headers: {
//       repeatSubmit: true,
//       "Content-Type": "application/json",
//     },
//     method: "post",
//     data: JSON.stringify(data),
//   });
// }

// 查询用户详细
export function getUser(data) {
  return request({
    url: editUserHuiXian_,
    method: "post",
    data: qs.stringify(data),
  });
}

// 修改用户
export function updateUser(data) {
  return request({
    url: eidtUser_,
    headers: {
      "Content-Type": "application/json",
    },
    method: "post",
    data: JSON.stringify(data),
  });
}
// 重置登录秘密的 验证码

export function eidtVcode(data) {
  return request({
    url: eidtVcode_,
    method: "get",
    params: data,
  });
}
// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password,
  };
  return request({
    url: "/system/user/resetPwd",
    method: "put",
    data: data,
  });
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: "/system/user/profile",
    method: "get",
  });
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: "/system/user/profile",
    method: "put",
    data: data,
  });
}

// 用户密码重置
export function updateUserPwd(data) {
  return request({
    url: resetPwd_,
    method: "post",
    data: qs.stringify(data),
  });
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: "/system/user/profile/avatar",
    method: "post",
    data: data,
  });
}

// 保存授权角色
export function updateAuthRole(data) {
  return request({
    url: "/system/user/authRole",
    method: "put",
    params: data,
  });
}

// 查询部门下拉树结构
export function deptTreeSelect() {
  return request({
    url: "/system/user/deptTree",
    method: "get",
  });
}
